{% extends BASE_TEMPLATE %}
{% load i18n foundation_alert %}

{% block view_content %}
  <div class="row">
    <div class="large-12 columns">
      <h1>{% trans 'DNS edit' %}</h1>
        {% if forms %}
          <table>
            <thead>
              {% for name, field in forms.0.fields.items %}
                <th>{{ field.label }}</th>
              {% endfor %}
              <th></th>
              <th></th>
            </thead>
            {% for form in forms %}
              {% if form.non_field_errors %}
                <tr class="field-row error">
                  <td colspan="{{ forms.0.fields.items|length|add:2 }}" class="error">
                    <ul class="errorlist">
                      {% for error in form.non_field_errors %}
                        <li>{{ error }}</li>
                      {% endfor %}
                    </ul>
                  </td>
                </tr>
              {% endif %}
              <tr>
                <form method="post" action="">
                {% csrf_token %}
                  {% for field in form %}
                    <td>{{ field }} {{ field.errors }}</td>
                  {% endfor %}
                  <td>
                    <input type="submit" class="button" value="{% trans 'Save' %}" />
                  </td>
                  <td>
                    {% if form.pk.value %}
                      <input type="submit" name="delete" class="button small alert" value="{% trans 'Delete' %}" onclick="return confirm('{% trans 'Are you sure to delete?' %}');" />
                    {% endif %}
                  </td>
                </form>
              </tr>
            {% endfor %}
          </table>
          <br />
        {% else %}
          <br />
          {% trans "Add at least one IP address to fetch DNS records." as message %}
          {% alert message 'warning' %}
        {% endif %}
    </div>
  </div>
{% endblock %}
